# -*- coding: utf-8 -*-
# -文件说明 IP查询。www.ip138.com-
# @Time    : 2019/8/8 16:33
# @Author  : hwx
# @Email   : @163.com
# @File    : 爬虫demo3_ip查询.py
# @Software: PyCharm
import requests


def getHTMLText3(url, pas):
    r = requests.get(url, pas)  # 请用get，用post出错
    print('状态码：' + str(r.status_code))
    print(r.request.url)
    r.raise_for_status()  # 如果不是200，抛出异常
    r.encoding = 'utf-8'
    return r.text


# http://www.ip138.com/ips138.asp?ip=223.89.156.55
url = "http://m.ip138.com/ip.asp"
params = {'ip': '223.89.156.55'}
print(getHTMLText3(url, params))
'''
或者直接拼网址
'''
# url2 = "http://m.ip138.com/ip.asp?ip=" + '223.89.156.55'
# re1 = requests.get(url2)
# print(re1.status_code)
# print(re1.text)
